<template>
	<div>
		<el-divider content-position="left">回收报价单配置（Token：<label
				style="color: red;argin-left: 10px;font-weight: bold;">至少每7天一更换</label>）</el-divider>
		<el-form ref="alForm" :model="alForm" :rules="alRules" size="small" label-width="150px">
			<el-row>
				<el-col :span="8">
					<el-form-item label="KG域名URL" prop="kg_yu_ming_url">
						<el-input v-model="alForm.kg_yu_ming_url" type="text" placeholder="请输入KG域名URL" />
					</el-form-item>
				</el-col>
				<el-col :span="14">
					<el-form-item label="配置Token" prop="kg_yu_ming_token">
						<el-input v-model="alForm.kg_yu_ming_token" type="textarea" placeholder="请输入配置Token" />
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="8">
					<el-form-item label="标题被替换名" prop="kg_img_clear_name">
						<el-input v-model="alForm.kg_img_clear_name" type="text" placeholder="请输入标题被替换名称" />
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="标题替换成名" prop="kg_img_replace_name">
						<el-input v-model="alForm.kg_img_replace_name" type="text" placeholder="请输入标题替换成名称" />
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="添加水印名" prop="kg_img_add_water_name">
						<el-input v-model="alForm.kg_img_add_water_name" type="text" placeholder="请输入添加水印名称" />
					</el-form-item>
				</el-col>

			</el-row>
			<el-row>
				<el-col :span="8">
					<el-form-item label="图片替换URL" prop="kg_img_replace_url">
						<el-input v-model="alForm.kg_img_replace_url" type="text" placeholder="请输入图片替换URL" />
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="图片替换(RGB)" prop="kg_img_replace_rgb">
						<el-input v-model="alForm.kg_img_replace_rgb" type="text" placeholder="请输入图片替换颜色(RGB)" />
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="水印颜色(RGB)" prop="kg_watermark_rgb">
						<el-input v-model="alForm.kg_watermark_rgb" type="text" placeholder="请输入水印颜色(RGB)" />
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="黄金Api地址" prop="kg_get_hj_api_url">
						<el-input v-model="alForm.kg_get_hj_api_url" type="text" placeholder="请输入黄金Api地址" />
					</el-form-item>
				</el-col>
				<el-col :span="2">
					<el-form-item label="">
						<el-button type="primary" @click="doAlSubmit('alForm')">设置</el-button>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<el-divider content-position="left">回收报价单除去水印颜色配置</el-divider>
		<RecoverySet></RecoverySet>
	</div>
</template>

<script>
	import checkPermission from '@/utils/permission'
	import initData from '@/mixins/crud'
	import {
		del,
		add,
		get,
		getGoldUrl
	} from '@/api/yxSystemConfig'
	import eForm from './form'
	import picUpload from '@/components/pic-upload'
	import RecoverySet from './components/RecoverySet'
	import {
		Message
	} from 'element-ui'
	export default {
		components: {
			eForm,
			picUpload,
			RecoverySet
		},
		dicts: ['is_enable'],
		mixins: [initData],
		data() {
			return {
				
				delLoading: false,
				alForm: {
					kg_yu_ming_url: '',
					kg_yu_ming_token: '',
					kg_img_replace_url: '',
					kg_img_replace_name: '',
					kg_img_clear_name: '',
					kg_img_add_water_name: '',
					kg_watermark_rgb: '',
					kg_img_replace_rgb: '',
					kg_get_hj_api_url: 'api/GoldQuote/index'
				},
				alRules: {
					kg_yu_ming_url: [{
						required: true,
						message: '请输入KG域名URL',
						trigger: 'blur'
					}],
					kg_yu_ming_token: [{
						required: true,
						message: '请输入配置Token',
						trigger: 'blur'
					}],
					kg_img_clear_name: [{
						required: true,
						message: '请输入标题被替换名称',
						trigger: 'blur'
					}],
					kg_img_replace_name: [{
						required: true,
						message: '请输入标题替换名称',
						trigger: 'blur'
					}],
					kg_img_replace_url: [{
						required: true,
						message: '请输入图片替换URL',
						trigger: 'blur'
					}],
					kg_img_add_water_name: [{
						required: true,
						message: '请输入添加水印名称',
						trigger: 'blur'
					}],
					kg_watermark_rgb: [{
						required: true,
						message: '请输入水印颜色(RGB)',
						trigger: 'blur'
					}],
					kg_img_replace_rgb: [{
						required: true,
						message: '请输入图片替换颜色(RGB)',
						trigger: 'blur'
					}],
					kg_get_hj_api_url: [{
						required: true,
						message: '请输入黄金Api地址',
						trigger: 'blur'
					}],
				},
			}
		},
		created() {
			get().then(rese => {
				const that = this;
				rese.content.map(function(key, value) {
					const keyName = key.menuName
					const newValue = key.value
					if (keyName in that.alForm) {
						that.alForm[keyName] = newValue
					}
				})
			})
		},
		methods: {
			checkPermission,
			doAlSubmit(formName) {
				this.$refs[formName].validate((valid) => {
					if (valid) {
						add(this.alForm).then(res => {
							Message({
								message: '设置成功',
								type: 'success'
							})
						}).catch(err => {
							this.loading = false
							console.log(err.response.data.message)
						})
					} else {
						console.log('error submit!!');
						return false;
					}
				});

			},
			
		}
	}
</script>

<style scoped>
</style>